<template>
    <div class="container-content">
        <!-- <el-row>
            <el-col :span="24">
                <h3 class="panel-title">新建客户</h3>
            </el-col>
        </el-row> -->
        <el-form
            ref="elForm"
            :model="formObject"
            label-width="80px"
            :rules="rules"
            status-icon
            label-position="left"
        >
            <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
                <el-tab-pane label="基本信息" name="basic">
                    <!-- 客户 -->
                    <div class="desc-title">客户</div>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item
                                label="创建组织"
                                prop="customerEntity.deptName"
                                label-width="110px"
                            >
                                <el-input
                                    disabled
                                    v-model="formObject.customerEntity.deptName"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="使用组织"
                                label-width="110px"
                            >
                                <el-input
                                    disabled
                                    v-model="formObject.customerEntity.deptName"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="简称"
                                prop="abbreviation"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请输入简称"
                                    v-model="
                                        formObject.customerEntity.abbreviation
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                       
                        <el-col :span="8">
                            <el-form-item
                                label="客户名称"
                                prop="customerEntity.customerName"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请输入客户名称"
                                    v-model="
                                        formObject.customerEntity.customerName
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 地址 -->
                    <div class="desc-title">地址</div>
                    <el-row :gutter="2">
                        <el-form-item
                            label="客户地址"
                            prop="country"
                            label-width="110px"
                        >
                            <el-col :span="2">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.provincesId
                                    "
                                    placeholder="省"
                                    @change="getCity"
                                >
                                    <el-option
                                        v-for="item in provinces"
                                        :key="item.id"
                                        :label="item.areaName"
                                        :value="item.id"
                                    >
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2">
                                <el-select
                                    v-model="formObject.customerEntity.cityId"
                                    placeholder="市"
                                    @change="getCounty"
                                >
                                    <el-option
                                        v-for="item in cities"
                                        :key="item.id"
                                        :label="item.areaName"
                                        :value="item.id"
                                    >
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="2">
                                <el-select
                                    v-model="formObject.customerEntity.countyId"
                                    placeholder="区/县"
                                >
                                    <el-option
                                        v-for="item in counties"
                                        :key="item.validue"
                                        :label="item.areaName"
                                        :value="item.id"
                                    >
                                    </el-option>
                                </el-select>
                            </el-col>
                            <el-col :span="18">
                                <el-input
                                    placeholder="请输入详细地址"
                                    v-model="formObject.customerEntity.address"
                                ></el-input>
                            </el-col>
                        </el-form-item>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="邮政编码" label-width="110px">
                                <el-input
                                    placeholder="请输入邮政编码"
                                    v-model="formObject.customerEntity.postCode"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司网址" label-width="110px">
                                <el-input
                                    placeholder="请输入公司网址"
                                    v-model="
                                        formObject.customerEntity.companyUrl
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 管理 -->
                    <div class="desc-title">管理</div>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="联系电话" label-width="110px">
                                <el-input
                                    placeholder="请输入联系电话"
                                    v-model="formObject.customerEntity.telPhone"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="传真" label-width="110px">
                                <el-input
                                    placeholder="请输入传真"
                                    v-model="
                                        formObject.customerEntity.facsimile
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司类别" label-width="110px">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.companyType
                                    "
                                    placeholder="请选择公司类别"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in companyTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="公司性质" label-width="110px">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.companyNature
                                    "
                                    placeholder="请选择公司性质"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in companyNatureOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司规模" label-width="110px">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.companySize
                                    "
                                    placeholder="请选择公司规模"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in companySizeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 注册 -->
                    <div class="desc-title">注册</div>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="法人代表" label-width="110px">
                                <el-input
                                    placeholder="请输入法人代表"
                                    v-model="
                                        formObject.customerEntity
                                            .legalRepresentative
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="注册资本" label-width="110px">
                                <el-input
                                    placeholder="请输入注册资本"
                                    v-model="
                                        formObject.customerEntity
                                            .registeredCapital
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="创立日期" label-width="110px">
                                <el-date-picker
                                    v-model="
                                        formObject.customerEntity.registeredTime
                                    "
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                    value-format="yyyy-MM-dd"
                                    format="yyyy-MM-dd"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="行业" label-width="110px">
                                <el-input
                                    placeholder="请输入行业"
                                    v-model="formObject.customerEntity.industry"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="注册地址" label-width="110px">
                                <el-input
                                    placeholder="请输入注册地址"
                                    v-model="
                                        formObject.customerEntity
                                            .registerAddress
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 开票信息 -->
                    <div class="desc-title">开票信息</div>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="发票抬头" label-width="110px">
                                <el-input
                                    placeholder="请输入发票抬头"
                                    v-model="
                                        formObject.customerEntity.invoiceHeader
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="纳税登记号"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请输入纳税登记号"
                                    v-model="formObject.customerEntity.taxId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="开户银行" label-width="110px">
                                <el-input
                                    placeholder="请输入开户银行"
                                    v-model="formObject.customerEntity.openBank"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="银行账号" label-width="110px">
                                <el-input
                                    placeholder="请输入银行账号"
                                    v-model="
                                        formObject.customerEntity.bankAccount
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="开票联系电话"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请输入开票联系电话"
                                    v-model="
                                        formObject.customerEntity.invoiceHotline
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="统一社会信用代码"
                                label-width="140px"
                            >
                                <el-input
                                    placeholder="请输入统一社会信用代码"
                                    v-model="
                                        formObject.customerEntity.unifiedCode
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="24">
                            <el-form-item
                                label="开票通讯地址"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请输入开票通讯地址"
                                    v-model="
                                        formObject.customerEntity.invoiceAddress
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 相关 -->
                    <div class="desc-title">相关</div>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item label="客户类别" label-width="110px">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.customerType
                                    "
                                    placeholder="请选择客户类别"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in customerTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="客户分组" label-width="110px">
                                <el-select
                                    v-model="
                                        formObject.customerEntity.customerGroup
                                    "
                                    placeholder="请选择客户分组"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in customerGroupOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="10">
                        <el-col :span="8">
                            <el-form-item
                                label="对应供应商"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="请选择对应供应商"
                                    v-model="
                                        formObject.customerEntity
                                            .counterSupplierName
                                    "
                                >
                                    <i
                                        slot="suffix"
                                        class="el-input__icon el-icon-notebook-2"
                                        style="cursor: pointer"
                                        @click="openDialog('supplier')"
                                    ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="对应集团客户"
                                label-width="110px"
                            >
                                <el-input
                                    placeholder="对应集团客户"
                                    v-model="
                                        formObject.customerEntity
                                            .counterCustomerName
                                    "
                                >
                                    <i
                                        slot="suffix"
                                        class="el-input__icon el-icon-notebook-2"
                                        style="cursor: pointer"
                                        @click="openDialog('customer')"
                                    ></i>
                                </el-input>
                                <!-- <el-checkbox-group v-model="">
                                  <el-checkbox label="集团客户" name="type"></el-checkbox>
                                  <el-checkbox label="默认付款方" name="type"></el-checkbox>
                                  <el-checkbox label="不校验可发量" name="type"></el-checkbox>
                                </el-checkbox-group> -->
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <el-form-item label="备注" label-width="110px">
                                <el-input
                                    type="textarea"
                                    v-model="formObject.customerEntity.remarks"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 智慧订货 -->
                    <div class="desc-title">智慧订货</div>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item
                                label="是否允许对接智慧订货"
                                label-width="164px"
                            >
                                <el-checkbox
                                    v-model="formObject.customerEntity.isAllow"
                                ></el-checkbox>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="联系人" name="more">
                    <el-button
                        type="text"
                        size="medium"
                        @click="addNewRow('contact')"
                        >新增行
                    </el-button>
                    <el-table
                        :data="formObject.contactsEntities"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            type="index"
                            label="序号"
                            width="55"
                            align="center"
                        ></el-table-column>
                        <el-table-column label="编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="code"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.code"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="姓名" width="150">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="name"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.name"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="性别">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="sex"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.sex"
                                        placeholder="请选择"
                                    >
                                        <el-option key="1" label="男" value="1">
                                        </el-option>
                                        <el-option key="2" label="女" value="2">
                                        </el-option>
                                        <el-option
                                            key="0"
                                            label="未知"
                                            value="0"
                                        >
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="职位">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="position"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.position"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="手机">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.phone"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="电话">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.tel"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="邮箱">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="传真">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.facsimile"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="地点编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.addressCode"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="地点名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.address"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="详细地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.detailAddress"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="默认收货地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isDefault"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="商务信息" name="business">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="结算币别" label-width="130px" prop="erpBusinessInformation.settlementCurrencyName">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .settlementCurrencyName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'settlementCurrency',
                                                   
                                                )
                                            "
                                        ></i>
                                    </el-input>
                                    
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="销售部门" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .salesDept
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'dept',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="销售组" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .salesGroupName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'salesGroup',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="销售员" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .salesName
                                    "
                                >
                                        <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'salesId',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="冻结状态" label-width="130px">
                                <el-input
                                    disabled
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .frozenState
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="冻结范围" label-width="130px">
                                <el-input
                                disabled
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .frozenScope
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="冻结人" label-width="130px">
                                <el-input
                                disabled
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .frozenBy
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="冻结日期" label-width="130px">
                                <el-date-picker
                                    disabled
                                    v-model="
                                            formObject.erpBusinessInformation
                                                .frozenTime
                                        "
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                    value-format="yyyy-MM-dd"
                                    format="yyyy-MM-dd"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="保证金比例（%）"
                                label-width="130px"
                            >
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .marginRatio
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="结算卡" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .settlementCard
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="结算方" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .settlementPartyName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'settlementParty',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="付款方" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation.payName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'pay',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item
                                label="默认联系人"
                                label-width="130px"
                            >
                                <el-input
                                disabled
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .defaultContacts
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="结算方式" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .settlementMethodName
                                    "
                                >
                                <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'settlementMethod',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="收款条件" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .paymentTermsName
                                    "
                                >
                                <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'paymentTerms',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="价目表" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .priceName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'price',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="折扣表" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .discountName
                                    "
                                >
                                    <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'discount',
                                                   
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="发票类型" label-width="130px">
                               
                                <el-select
                                v-model="
                                        formObject.erpBusinessInformation
                                            .invoiceType
                                    "
                                    placeholder="请选择"
                                    style="width:100%"
                                >
                                    <el-option
                                        v-for="item in invoiceTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        
                        <el-col :span="8">
                            <el-form-item label="默认税率" label-width="130px">
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .defaultTaxRateName
                                    "
                                >
                                <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'taxRate',
                                                )
                                            "
                                        ></i>
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="运输提前期"
                                label-width="130px"
                            >
                                <el-input
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .transLeadTime
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="税分类" label-width="130px">
                                <el-select
                                    v-model="
                                        formObject.erpBusinessInformation
                                            .taxClass
                                    "
                                    placeholder="请选择"
                                    style="width:100%"
                                >
                                    <el-option
                                        v-for="item in taxClassOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="启用信用管理"
                                label-width="130px"
                            >
                                <el-checkbox 
                                    v-model="formObject.erpBusinessInformation.isCreditAgency">
                                </el-checkbox>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="银行信息" name="bank">
                    <el-button
                        type="text"
                        size="medium"
                        @click="addNewRow('bank')"
                        >新增行
                    </el-button>
                    <el-table
                        :data="formObject.bankEntities"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete_bank(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            type="index"
                            label="序号"
                            width="55"
                            align="center"
                        ></el-table-column>

                        <el-table-column prop="openingCountry" label="开户国家">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.openingCountry"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in openingCountryData"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value"
                                        >
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="bankAccount" label="银行账号">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.bankAccount"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="accountName" label="账户名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.accountName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="dueBanke" label="收款银行">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.dueBanke"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="brancheName" label="网点名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.brancheName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="bankBranches" label="银行网点">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.bankBranches"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="openBankAddress"
                            label="开户行地址"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.openBankAddress"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="bankName" label="开户银行">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.bankName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="unionPayAccount" label="联行号">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.unionPayAccount"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column prop="currencyName" label="币别">
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.currencyName"
                                        clearable
                                    >
                                        <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'currency',
                                                    scope.$index
                                                )
                                            "
                                        ></i>
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="isDefault"
                            label="默认"
                            width="50"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isDefault"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="地址信息" name="adress">
                    <el-button
                        type="text"
                        size="medium"
                        @click="addNewRow('address')"
                        >新增行
                    </el-button>
                    <el-table
                        :data="formObject.addresses"
                        style="width: 100%"
                        border
                    >
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete_address(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="addressCode"
                            label="地点编码"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.addressCode"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="addressName"
                            label="地点名称"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.addressName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="detilAddress"
                            label="详细地址"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.detilAddress"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="transLeadTime"
                            label="运输提前期"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.transLeadTime"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="contacts"
                            label="联系人"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.contacts"
                                        clearable
                                    >
                                        <i
                                            slot="suffix"
                                            class="el-input__icon el-icon-notebook-2"
                                            style="cursor: pointer"
                                            @click="
                                                openDialog(
                                                    'contacts',
                                                    scope.$index
                                                )
                                            "
                                        ></i>
                                    </el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="fixedPhone"
                            label="固定电话"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.fixedPhone"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="phone"
                            label="移动电话"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.phone"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="email"
                            label="电子邮箱"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="isDefaltAddress"
                            label="默认收货地址"
                            align="center"
                            width="150"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isDefaltAddress"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="isDefaultBillAddress"
                            label="默认开票地址"
                            width="150"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isDefaultBillAddress"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="isDefaultPayAddress"
                            label="默认付款地址"
                            width="150"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isDefaultPayAddress"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop="isUsed"
                            label="启用"
                            width="150"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isUsed"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column
                            prop=""
                            label="地址禁用状态"
                            width="150"
                            align="center"
                        >
                            <template slot-scope="scope">
                                <el-form-item
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-checkbox
                                        v-model="scope.row.isUsed"
                                    ></el-checkbox>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
            <!-- <el-form-item label-width="0px" style="margin-top: 20px">
                <el-button
                    type="primary"
                    size="medium"
                    @click="formSubmit('basicFormRef')"
                >保存
                </el-button
                >
                <el-button size="medium" @click="formRest('basicFormRef')"
                >取消
                </el-button
                >
            </el-form-item> -->
        </el-form>
        <el-dialog
            :title="dialogTitle"
            :visible.sync="dialog"
            append-to-body
            width="70%"
            destroy-on-close
            v-if="dialog"
        >
            <component
                :is="currentCom"
                :id="rowId"
                :deptLevel="deptLevel"
                :type="type"
                :visible.sync="dialog"
                @getSelectVal="getSelectVal"
            ></component>
            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelSelect">取 消</el-button>
                <el-button type="primary" @click="confirmSelect"
                    >确 定</el-button
                >
            </span>
        </el-dialog>
    </div>
</template>
<script>
import { addCustomer,saveCustomer,submitCustomer } from "@/api/system/customer";
import { getAreaList } from "@/api/area/area";
import { getCurrencyData,getTaxData,getPayData } from "@/api/base/data";
import { getInfo } from "@/api/login";
import Supplier from "@/components/dialog/supplier";
import Customer from "@/components/dialog/customer";
import Currency from "@/components/dialog/currency";
import Contacts from "@/components/dialog/contacts";
import Dept from "@/components/dialog/dept";
import BussinessGroup from "@/components/dialog/businessGroup";
import SaleId from "@/components/dialog/saleId";
import SettlementType from "@/components/dialog/settlementType";
import ReceiptmentTerms from "@/components/dialog/receiptmentTerms";
import Price from "@/components/dialog/priceinfoId";
import TaxRate from "@/components/dialog/taxRate";

export default {
    components: {
        Supplier,
        Customer,
        Currency,
        Contacts,
        Dept,
        BussinessGroup,
        SaleId,
        SettlementType,
        ReceiptmentTerms,
        Price,
        TaxRate
    },
    props: {},
    data() {
        return {
            activeName: "basic",
            dialogType: "",
            listIndex: "",
            dialog: false,
            currentCom: "",
            rowId: "",
            type:"",
            dialogTitle: "",
            deptLevel:2,
            selectItem: [],
            currentCom:"",
            formObject: {
                customerEntity: {
                    abbreviation: "", //简称
                    customerName: "", //客户名称
                    provincesId: "", //省
                    cityId: "", //市
                    countyId: "", //区
                    address: "", //详细地址
                    postCode: "", //邮政编码
                    companyUrl: "", //公司网址
                    telPhone: "", //联系电话
                    facsimile: "", //传真
                    companyType: "", //公司类别
                    companyNature: "", //公司性质
                    companySize: "", //公司规模
                    legalRepresentative: "", //法人代表
                    registeredCapital: "", //注册资本
                    registeredTime: this.parseTime(new Date()), //创立日期
                    industry: "", //行业
                    registerAddress: "", //注册地址
                    invoiceHeader: "", //开票抬头
                    taxId: "", //纳税登记号
                    openBank: "", //开户银行
                    bankAccount: "", //银行账号
                    invoiceHotline: "", //开票联系电话
                    invoiceAddress: "", //开票地址
                    unifiedCode: "", //统一社会信用代码
                    customerType: "", //客户类别
                    customerGroup: "", //客户分组
                    counterDept: "", //对应组织
                    counterSupplier: "", //对应供应商
                    counterSupplierName: "", //对应供应商名称
                    counterCustomerId: "", //对应集团客户
                    counterCustomerName: "", //对应集团客户名称
                    remarks: "", //备注
                    isAllow: "", //是否允许智慧订货
                    invoiceEmail: "",
                    type: 3,
                    deptName: "",
                    deptId: "",
                    businessType: "42",
                    modelId: this.$store.state.workflow.businessConfig.id,
                },
                erpBusinessInformation: {
                    settlementCurrency: "", //结算币别
                    settlementCurrencyName:"",//结算币别名称
                    salesDept: "", //销售部门
                    salesDeptName:"",//销售部门名称
                    salesGroup: "", //销售组
                    salesGroupName:"",//销售组名称
                    salesId: "", //销售员
                    salesName: "", //销售员名称
                    frozenState: "", //冻结状态
                    frozenScope: "", //冻结范围
                    frozenBy: "", //冻结人
                    frozenTime: "", //冻结日期
                    marginRatio: "", //保证金比例
                    settlementCard: "", //结算卡
                    settlementPartyId: "", //结算方
                   
                    settlementPartyName: "", //结算方名称
                    payId: "", //付款方
                    payName:"",//付款方名称
                    defaultContacts: "", //默认联系人
                    settlementMethod: "", //结算方式
                    settlementMethodCode:"", //结算方式编码
                    settlementMethodName: "", //结算方式名称
                    paymentTerms: "", //收款条件
                    paymentTermsName: "", //收款条件名称
                    priceId: "", //价目表
                    priceName: "", //价目表名称
                    discountId: "", //折扣表
                    discountName: "", //折扣表名称
                    defaultContacts: "", //默认联系人
                    invoiceType: "", //发票类型
                    defaultTaxRate: "", //默认税率
                    defaultTaxRateName:"",//默认税率名称
                    transLeadTime: "", //运输提前期
                    taxClass: "", //税分类
                    isCreditAgency: "", //启用信用管理
                },
                contactsEntities: [],
                bankEntities: [],
                addresses: [],
            },
            provinces: [],
            openingCountryData: [],
            cities: [],
            counties: [],
            companySizeOptions: [],
            companyNatureOptions: [],
            companyTypeOptions: [],
            customerTypeOptions: [],
            customerGroupOptions: [],
            invoiceTypeOptions:[],
            
            taxClassOptions:[],
            rules: {
                customerEntity:{
                    deptName: [
                      { required: true, message: "", trigger: "blur" },
                    ],
                    customerName: [
                      { required: true, message: "请输入客户名称！", trigger: "blur" },
                    ],
                },
                erpBusinessInformation:{
                    settlementCurrencyName: [
                        { required: true, message: "请选择结算币别！", trigger: "blur" },
                    ],
                }
            },
        };
    },
    methods: {
        // 页签切换事件
        handleClick(tab, event) {
            console.log(tab, event);
        },
        // 附件上传
        handleFileChange() {
            console.log("文件上传");
        },
        // 选择弹窗 item
        getSelectVal(val,isDbleclick) {
            this.selectItem = val
            if(isDbleclick){
                this.confirmSelect()
            }
        },
        cancelSelect() {
            this.dialog = false;
            this.selectItem = [];
        },
        // 提交
        submit() {
          const cb = (res) => {
            const obj = {
              id: res.data,
              businessType: "42",
              modelId: this.$store.state.workflow.businessConfig.id,
            };
            submitCustomer(obj).then((res) => {
              if (res.code === 200) {
                this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                this.$message({
                  message: "提交成功！",
                  type: "success",
                });
              }
            });
          };
          this.temporaryStorage(cb);
        },
         // 暂存
         temporaryStorage(cb) {
          this.$refs["elForm"].validate((valid) => {
            if (!valid) {
              this.$message.error("请填写完整信息！");
              return;
            }
            // TODO 提交表单
            saveCustomer(this.formObject).then((res) => {
              if (res.code === 200) {
                if (cb) {
                  cb(res);
                  return;
                }
                this.$store.commit("workflow/SET_BUSINESSDRAWER", false);
                this.$message({
                  message: "暂存成功！",
                  type: "success",
                });
              }
            });
          });
        },
        // 基础表单取消
        formRest(basicFormRef) {
            this.$refs[basicFormRef].resetFields();
        },
        // 更多联系人表单 添加行
        handleDataAdd() {
            if (this.formObject.contactsEntities == undefined) {
                this.formObject.contactsEntities = [];
            }
            let obj = {};
            obj.address = "";
            obj.addressCode = "";
            obj.email = "";
            obj.facsimile = "";
            obj.email = "";
            obj.tel = "";
            obj.phone = "";
            obj.name = "";
            obj.position = "";
            obj.isDefault = true;
            obj.company = "";
            obj.sex = "";
            this.formObject.contactsEntities.push(obj);
        },
        // 更多联系人表单 删除行
        handleDataDelete(index, row) {
            this.$confirm("请确认是否要删除此行？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                    this.formObject.contactsEntities.splice(index, 1);
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        //银行信息表单 添加行
        handleDataAdd_bank() {
            if (this.formObject.bankEntities == undefined) {
                this.formObject.bankEntities = [];
            }
            let obj = {};
            obj.openingCountry = "";
            obj.bankAccount = "";
            obj.accountName = "";
            obj.dueBanke = "";
            obj.brancheName = "";
            obj.bankBranches = "";
            obj.openBankAddress = "";
            obj.bankName = "";
            obj.unionPayAccount = "";
            obj.currency = "";
            obj.currencyName = "";
            obj.isDefault = true;
            let parentId = 0;
            getAreaList({ parentId }).then((res) => {
                if (res.code === 200) {
                    this.openingCountryData = res.rows.map((item) => {
                        return {
                            value: item.id,
                            label: item.areaName,
                        };
                    });
                }
            });
            getCurrencyData().then((res) => {
                obj.currency = res.rows[0].code;
                obj.currencyName = res.rows[0].currencyName;
            });
            this.formObject.bankEntities.push(obj);
        },
        //银行信息表单 删除行
        handleDataDelete_bank(index, row) {
            this.$confirm("请确认是否要删除此行?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.formObject.bankEntities.splice(index, 1);
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        //地址表单 添加行
        handleDataAdd_address() {
            if (this.formObject.addresses == undefined) {
                this.formObject.addresses = [];
            }
            let obj = {};
            obj.addressCode = "";
            obj.addressName = "";
            obj.detilAddress = "";
            obj.transLeadTime = "";
            obj.contacts = "";
            obj.fixedPhone = "";
            obj.phone = "";
            obj.email = "";
            obj.isDefaltAddress = "";
            obj.isDefaultBillAddress = "";
            obj.isDefaultPayAddress = "";
            obj.isUsed = "";
            this.formObject.addresses.push(obj);
        },
        //银行信息表单 删除行
        handleDataDelete_address(index, row) {
            this.$confirm("请确认是否要删除此行?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.formObject.addresses.splice(index, 1);
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        //新增行
        addNewRow(type) {
            if (type === "address") {
                this.handleDataAdd_address();
            } else if (type === "bank") {
                this.handleDataAdd_bank();
            } else {
                this.handleDataAdd();
            }
        },
        //默认获取省列表
        getProvince(parentId) {
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.provinces = res.rows;
            });
        },
        //点击省份获取城市列表
        getCity(parentId) {
            this.formObject.customerEntity.cityId = "";
            this.formObject.customerEntity.countyId = "";
            this.counties = [];
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.cities = res.rows;
            });
        },
        //点击城市获取区县列表
        getCounty(parentId) {
            this.formObject.customerEntity.countyId = "";
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.counties = res.rows;
            });
        },
        openDialog(val, index) {
            this.dialog = true;
            this.dialogType = val;
            this.listIndex = index;
            this.refresh();
        },
        refresh() {
            const nameMap = {
                supplier: () => {
                    this.dialogTitle = "选择供应商";
                    this.currentCom = Supplier;
                },
                customer: () => {
                    this.dialogTitle = "选择客户";
                    this.currentCom = Customer;
                },
                currency: () => {
                    this.dialogTitle = "选择币别";
                    this.currentCom = Currency;
                },
                settlementCurrency:()=>{
                    this.dialogTitle = "选择币别";
                    this.currentCom = Currency;
                },
                contacts: () => {
                    this.dialogTitle = "选择联系人";
                    this.currentCom = Contacts;
                },
                dept:()=>{
                    this.dialogTitle = "选择部门";
                    this.currentCom = Dept;
                    this.deptLevel = 2
                },
                salesGroup:()=>{
                    this.dialogTitle = "选择业务组";
                    this.currentCom = BussinessGroup;
                },
                salesId:()=>{
                    this.dialogTitle = "选择销售员";
                    this.currentCom = SaleId;
                },
                settlementParty:()=>{
                    this.dialogTitle = "选择结算方";
                    this.currentCom = Customer;
                },
                pay:()=>{
                    this.dialogTitle = "选择付款方";
                    this.currentCom = Customer;
                },
                settlementMethod:()=>{
                    this.dialogTitle = "选择结算方式";
                    this.currentCom = SettlementType;
                },
                paymentTerms:()=>{
                    this.dialogTitle = "选择收款条件";
                    this.currentCom = ReceiptmentTerms;
                },
                price:()=>{
                    this.dialogTitle = "选择价目表";
                    this.currentCom = Price;
                    this.type = 0;
                },
                discount:()=>{
                    this.dialogTitle = "选择折扣表";
                    this.currentCom = Price;
                    this.type = 1;
                },
                taxRate:()=>{
                    this.dialogTitle = "选择税率";
                    this.currentCom = TaxRate;
                },
                
            };
            nameMap[this.dialogType] ? nameMap[this.dialogType]() : "";
        },
        confirmSelect() {
            const nameMap = {
                supplier: () => {
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.customerEntity.counterSupplier =
                        this.selectItem[0].id;
                    this.formObject.customerEntity.counterSupplierName =
                        this.selectItem[0].supplierName;
                    this.dialog = false;
                },
                customer: () => {
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.customerEntity.counterCustomerId =
                        this.selectItem[0].id;
                    this.formObject.customerEntity.counterCustomerName =
                        this.selectItem[0].customerName;
                    this.dialog = false;
                },
                currency: () => {
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.bankEntities[this.listIndex].currency =
                        this.selectItem[0].id;
                    this.formObject.bankEntities[this.listIndex].currencyName =
                        this.selectItem[0].currencyName;
                    this.dialog = false;
                },
                settlementCurrency:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.settlementCurrency =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.settlementCurrencyName =
                        this.selectItem[0].currencyName;
                    this.dialog = false;
                },
                contacts: () => {
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.bankEntities[this.listIndex].contacts =
                        this.selectItem[0].userId;
                    this.formObject.bankEntities[this.listIndex].contactsName =
                        this.selectItem[0].name;
                    this.dialog = false;
                },
                dept:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.salesDept =
                        this.selectItem[0].deptId;
                    this.formObject.erpBusinessInformation.salesDeptName =
                        this.selectItem[0].deptName;
                    this.dialog = false;
                },
                salesGroup:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.salesGroup =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.salesGroupName =
                        this.selectItem[0].businessGroupType;
                    this.dialog = false;
                },
                salesId:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.salesId =
                        this.selectItem[0].userId;
                    this.formObject.erpBusinessInformation.salesName =
                        this.selectItem[0].userName;
                    this.dialog = false;
                },
                settlementParty:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.settlementPartyId =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.settlementPartyName =
                        this.selectItem[0].customerName;
                    this.dialog = false;
                },
                pay:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.payId =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.payName =
                        this.selectItem[0].customerName;
                    this.dialog = false;
                },
                settlementMethod:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    
                    this.formObject.erpBusinessInformation.settlementMethod =
                        this.selectItem[0].id;
                        this.formObject.erpBusinessInformation.settlementMethodCode =
                        this.selectItem[0].bizCode;
                    this.formObject.erpBusinessInformation.settlementMethodName =
                        this.selectItem[0].title;
                    this.dialog = false;
                },
                paymentTerms:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.paymentTerms =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.paymentTermsName =
                        this.selectItem[0].title;
                    this.dialog = false;
                },
                price:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.priceId =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.priceName =
                        this.selectItem[0].name;
                    this.dialog = false;
                },
                discount:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.discountId =
                        this.selectItem[0].id;
                    this.formObject.erpBusinessInformation.discountName =
                        this.selectItem[0].name;
                    this.dialog = false;
                },
                taxRate:()=>{
                    if (this.selectItem.length !== 1) {
                        this.$message.error("请选择一条记录！");
                        return;
                    }
                    this.formObject.erpBusinessInformation.defaultTaxRate =
                        this.selectItem[0].rate;
                    this.formObject.erpBusinessInformation.defaultTaxRateName =
                        this.selectItem[0].title;
                    this.dialog = false;
                }

            };
            nameMap[this.dialogType] ? nameMap[this.dialogType]() : "";
        },
        // 默认数据请求
        initDefaultData() {
            // 获取组织
            getInfo().then((res) => {
                this.formObject.customerEntity.deptId = res.deptId;
                this.formObject.customerEntity.deptName = res.deptName;
            });

            // 公司规模
            this.getDicts("company_size").then((res) => {
                if (res.code === 200) {
                    this.companySizeOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 结算币别
            getCurrencyData().then((res) => {
                this.formObject.erpBusinessInformation.settlementCurrency = res.rows[0].id;
                this.formObject.erpBusinessInformation.settlementCurrencyName = res.rows[0].currencyName;
            });
            // 税率
            getTaxData().then((res) => {
                this.formObject.erpBusinessInformation.defaultTaxRate = res.rows[0].rate;
                this.formObject.erpBusinessInformation.defaultTaxRateName = res.rows[0].title;
            });
            // 收款条件
            getPayData({type:1}).then((res) => {
               
                this.formObject.erpBusinessInformation.paymentTermsName = res.data.records[0].title;
                this.formObject.erpBusinessInformation.paymentTerms = res.data.records[0].id;
            });
            // 公司性质
            this.getDicts("company_nature").then((res) => {
                if (res.code === 200) {
                    this.companyNatureOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 公司类别
            this.getDicts("company_type").then((res) => {
                if (res.code === 200) {
                    this.companyTypeOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 客户类别
            this.getDicts("customer_type").then((res) => {
                if (res.code === 200) {
                    this.customerTypeOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 客户分组
            this.getDicts("customer_group").then((res) => {
                if (res.code === 200) {
                    this.customerGroupOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 发票类型 
            this.getDicts("FPLX_SYS").then((res) => {
                if (res.code === 200) {
                    this.invoiceTypeOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
            // 税分类  
            this.getDicts("SFL_SYS").then((res) => {
                if (res.code === 200) {
                    this.taxClassOptions = res.data.map((item) => {
                        return {
                            value: item.dictCode,
                            label: item.dictLabel,
                        };
                    });
                }
            });
        },
    },
    created() {
        // 查询中国下属省份
        this.getProvince("20230705392153575054249984");
        this.initDefaultData();
    },
};
</script>
<style lang="scss" scoped>
// .add {
//   padding: 15px;
// }
.panel-title {
    font-size: 18px;
    color: #37474f;
    font-weight: 500;
    text-shadow: rgba(0, 0, 0, 0.15) 0 0 1px;
}

::v-deep .el-form-item__content {
    margin-left: 0;
}

.main-responsible {
    font-size: 14px;
    font-weight: 550;
    color: #263238;
    position: relative;
    text-indent: 15px;
}
</style>
